package com.EAIPClub.UserBaseInfoDataManager.mapper;

import com.api.POJO.UserBaseInfoManager.BaseInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description :用户基本信息管理模块Mapper
 * @Author :崔昌赫
 * @Date : 2021/10/21
 */
@Mapper
@Repository
public interface UserBaseInfoDataManagerMapper {
    @Select("SELECT * FROM base_info WHERE 1=1")
    List<BaseInfo> findAllBaseInfo();

    @Insert("INSERT INTO base_info VALUES('${baseinfo.uid}','${baseinfo.name}','${baseinfo.classes}','${baseinfo.studentid}')")
    Boolean addNewBaseInfo(@Param("baseinfo")BaseInfo baseInfo);

    @Select("SELECT * FROM base_info WHERE uid='${uid}'")
    BaseInfo findBaseInfoByUid(@Param("uid") String uid);
    @Select("SELECT * FROM base_info WHERE name='${name}'")
    List<BaseInfo> findBaseInfoByName(@Param("name")String name);
    @Select("SELECT * FROM base_info WHERE classes='${classes}'")
    List<BaseInfo> findBaseInfoByClass(@Param("classes")String classes);
    @Select("SELECT * FROM base_info WHERE studentid='${studentid}'")
    BaseInfo findBaseInfoByStudentId(@Param("studentid")String studentId);

    @Update("UPDATE base_info SET uid='${baseinfo.uid}',name='${baseinfo.name}',classes='${baseinfo.classes}',studentid='${baseinfo.studentid}' WHERE uid='${uid}'")
    Boolean updateBaseInfoByUid(@Param("uid")String uid,@Param("baseinfo")BaseInfo baseInfo);
    @Update("UPDATE base_info SET uid='${baseinfo.uid}',name='${baseinfo.name}',classes='${baseinfo.classes}',studentid='${baseinfo.studentid}' WHERE name='${name}'")
    Boolean updateBaseInfoByName(@Param("name")String name,@Param("baseinfo")BaseInfo baseInfo);
    @Update("UPDATE base_info SET uid='${baseinfo.uid}',name='${baseinfo.name}',classes='${baseinfo.classes}',studentid='${baseinfo.studentid}' WHERE classes='${classes}'")
    Boolean updateBaseInfoByClass(@Param("classes")String classes,@Param("baseinfo")BaseInfo baseInfo);
    @Update("UPDATE base_info SET uid='${baseinfo.uid}',name='${baseinfo.name}',classes='${baseinfo.classes}',studentid='${baseinfo.studentid}' WHERE studentid='${studentid}'")
    Boolean updateBaseInfoByStudentId(@Param("studentid")String studentId,@Param("baseinfo")BaseInfo baseInfo);

    @Delete("DELETE FROM base_info WHERE uid='${uid}'")
    Boolean deleteBaseInfoByUid(@Param("uid")String uid);
    @Delete("DELETE FROM base_info WHERE name='${name}'")
    Boolean deleteBaseInfoByName(@Param("name")String name);
    @Delete("DELETE FROM base_info WHERE classes='${classes}'")
    Boolean deleteBaseInfoByClass(@Param("classes")String classes);
    @Delete("DELETE FROM base_info WHERE studentid='${studentid}'")
    Boolean deleteBaseInfoByStudentId(@Param("studengid")String studentId);



}
